package tiantao.taogu.TgEnum;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 医院等级
 * @author jinjianming
 */
public enum HospitalGradeEnum {
  THREE_Y("三级医院", 34,"third"),
  THREE_T("三级特等", 33,"thirdS"),
  THREE_A("三级甲等", 32,"thirdA"),
  THREE_B("三级乙等", 31,"thirdB"),
  THREE_C("三级丙等", 30,"thirdC"),
  TWO_Y("二级医院", 23,"second"),
  TWO_A("二级甲等", 22,"secondA"),
  TWO_B("二级乙等", 21,"secondB"),
  TWO_C("二级丙等", 20,"secondC"),
  ONE_Y("一级医院", 13,"first"),
  ONE_A("一级甲等", 12,"firstA"),
  ONE_B("一级乙等", 11,"firstB"),
  ONE_C("一级丙等", 10,"firstC"),
  NONE("未评级", 0,"none");

  private String name;

  private int id;
  private String key;

  private HospitalGradeEnum(String name, int id, String key) {
    this.name = name;
    this.id = id;
    this.key = key;
  }

  public static HospitalGradeEnum valueOf(int id) {
    for (HospitalGradeEnum o : HospitalGradeEnum.values()) {
      if (o.getId() == id) {
        return o;
      }
    }
    return null;
  }

  public static String getName(int id) {
    for (HospitalGradeEnum o : HospitalGradeEnum.values()) {
      if (o.getId() == id) {
        return o.name;
      }
    }
    return "";
  }

  public static Integer getIdByName(String name) {
    for (HospitalGradeEnum o : HospitalGradeEnum.values()) {
      if (name.equals(o.getName())) {
        return o.id;
      }
    }
    return null;
  }

  public static List<HospitalGradeEnum> allGrades() {
    List<HospitalGradeEnum> rtn = new ArrayList<HospitalGradeEnum>();

    for (HospitalGradeEnum o : HospitalGradeEnum.values()) {
      rtn.add(o);
    }

    Collections.reverse(rtn);

    return rtn;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  /** 
   * @return key 
   */
  public String getKey() {
    return key;
  }

  /**
   * @param key the key to set
   */
  public void setKey(String key) {
    this.key = key;
  }
  
}